// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.core.Collections;

import java.io.Serializable;
import java.util.AbstractSet;
import java.util.Iterator;

public class NonBlockingHashSet<E> extends AbstractSet<E> implements Serializable {
    private static final Object V = "";
    private final NonBlockingHashMap<E, Object> _map = new NonBlockingHashMap<>();

    public boolean add(E object) {
        return this._map.putIfAbsent((E)object, V) != V;
    }

    public boolean contains(Object o) {
        return this._map.containsKey(o);
    }

    public boolean remove(Object o) {
        return this._map.remove(o) == V;
    }

    public int size() {
        return this._map.size();
    }

    public void clear() {
        this._map.clear();
    }

    public Iterator<E> iterator() {
        return this._map.keySet().iterator();
    }

    public void readOnly() {
        throw new RuntimeException("Unimplemented");
    }
}
